package com.nhncorp.pleiades.client;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.nhncorp.pleiades.conf.PleiadesConfiguration;

public class PleiadesClientFactory {

  public static final Log LOG = LogFactory.getLog(PleiadesClientFactory.class
      .getName());
  
  private static volatile PleiadesClientFactory _factory = null;

  private PleiadesClientFactory() { }

  /**
   * Singular public method to get access to any of the PleiadesClientFactory
   * Manager implementations. 
   * @return PleiadesClientFactory;
   */
  public static PleiadesClientFactory getInstance() {
      LOG.error(" getting factory instance ");
      if (_factory == null)
          _factory = new PleiadesClientFactory();
      return _factory;
  }
  
  public synchronized LockService createLockServiceClient() throws Exception {
    return LockServiceClientFactory.newInstance(new PleiadesConfiguration());
  }

  public synchronized LockService createLockServiceClient(PleiadesUser userInfo)
      throws Exception {
    return LockServiceClientFactory.newInstance(userInfo,
        new PleiadesConfiguration());
  }

  public synchronized EventService createEventServiceClient() throws Exception {
    return EventServiceClientFactory.newInstance(new PleiadesConfiguration());
  }

  public synchronized EventService createEventServiceClient(
      PleiadesUser userInfo) throws Exception {
    return EventServiceClientFactory.newInstance(userInfo,
        new PleiadesConfiguration());
  }    

}
